/// File: Robotics4.NET\BodyMap\XMLSerializerPool.cs
/// 
/// ------------------------------------------------------------
/// Copyright (c) 2004
///   Antonio Cisternino (cisterni.unipi.it),
///   Diego Colombo      (colombod.unipi.it)
/// 
/// The use and distribution terms for this software are 
/// contained in the file named license.txt, which can be found 
/// in the root of this distribution.
/// By using this software in any fashion, you are agreeing to 
/// be bound by the terms of this license.
///
/// You must not remove this notice, or any other, from this
/// software.
/// ------------------------------------------------------------

using System;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
#if WIN
using System.Collections.Generic;
using SerializerTable = System.Collections.Generic.Dictionary<System.String, System.Xml.Serialization.XmlSerializer>;
#endif
using System.Text;

namespace Robotics4.NET
{
	public class XMLSerializerPool
	{
		protected SerializerTable serializers = new SerializerTable();

        private string UniqueName(Type t, string m)
        {
            return string.Format("{0}::{1}", t.FullName, m);
        }

		public XmlSerializer this[Type messageType, string RobletName]
		{
			get{
                string key = UniqueName(messageType, RobletName);
				if (serializers.ContainsKey(key))
					return serializers[key];
				else
					return null;
			}

			set{
                serializers[UniqueName(messageType, RobletName)] = value;
			}
		}
	}
}
